<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>简易ATM取款机案例</title>
</head>
<body>
  <script>
    let money = 1000
    while(true){
    let re =+prompt(`请您选择操作:
      1.存钱 
      2.取钱 
      3.查看余额 
      4.退出`)
      if (re == 4){
        break
      }
      switch(re){
        case 1:
        let cun = +prompt('请输入存款金额')
        money += cun
          alert(`您现在的余额是${money}`)
        break
        case 2:
        let qu = +prompt('请输入取款金额')
        if (qu >money){
          alert(`您的余额不足,只能取${money}`)
          break
      } 
        else if (qu <money){
          money -= qu
        alert(`余额剩余${money}`)
        break
      }     
        case 3:
          alert(`您的银行卡余额是${money}`)
          break
        default:
          alert('无效的选择，请重新输入')
          break
      }
    }

  </script>
</body>
</html>